<?php
     include_once('../src/classes/class.mysql.php');
    
     $comtec_id_operation = $_POST['comtec_id_operation'];
     $token = $_POST['token']; 
     
     //TODO validar el token recibido por POST y el de la sesion.
     
     $db = new MySQL();  
     $tsql = "UPDATE operation SET status_reg=0 WHERE 
              comtec_id_operation=".$comtec_id_operation;
     if($db->query($tsql))
     {       
      if($_POST['type'] == 1){   
       $result = $db->fetch_array($db->query("
        SELECT comtec_id_machine FROM operation WHERE comtec_id_operation=$comtec_id_operation
       "));
       $comtec_id_machine = $result['comtec_id_machine'];
       echo "<script>loadOrders($comtec_id_machine);</script>"; 
      }elseif($_POST['type'] == 2){
       echo "<script>loadHome();</script>";
      }elseif($_POST['type'] == 3){
       echo "<script>searchOperations();</script>";         
      }
     } 
     else
     {
      echo '<p class="error">';
      echo "Error al eliminar la operacion \n";  
      echo '</p';              
     }
?>
